#ifndef RENDERABLE_H
#define RENDERABLE_H

#include "Actor.h"
#include "Color.h"
#include "Material.h"

NS_B2D_BEGIN

class Geometry;
class Camera;

///
/// Base class for all renderable objects
///
class Renderable
	: public Actor
{
protected:
	Material mMaterial;
	Geometry* mGeometry;

	bool mVisible;

private:
	bool mIsDirty;

public:
	virtual ~Renderable(void);

	/// Check for visibility
	bool isVisible(void) const { return mVisible; }
	/// Set visibility
	void setVisible(bool visible) { mVisible = visible; }

	/// Get material (read-only)
	const Material& getMaterial(void) const { return mMaterial; }
	/// Get material (read-write)
	Material& getMaterial(void) { return mMaterial; }

	/// Get geometry
	Geometry* getGeometry(void) const;
	/// Set geometry
	void setGeometry(Geometry* geom);

	/// Check if renderable data is out of data
	bool isDirty(void) { return mIsDirty; }
	/// Mark the renderable data as out of data
	void markDirty(void) { mIsDirty = true; }
	/// Update renderable if it has been marked as dirty
	void updateRenderable(const Camera* cam);

protected:
	Renderable(Scene* scene, const String& name);

private:
	/// Implementation of render data update
	virtual void updateRenderableImpl(const Camera* cam) { }
};

NS_B2D_END

#endif